package com.suineg.pms.commons.wabacus;

import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.suineg.pms.service.account.ShiroDbRealm.ShiroUser;
import com.wabacus.system.ReportRequest;
import com.wabacus.system.intercept.AbsPageInterceptor;

/**
 *wabacus页面的初始化用户信息
 *@author Suine
 */
public class InitLoginUserIntercepter extends AbsPageInterceptor{
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Override
	public void doStart(ReportRequest rrequest) {
		ShiroUser user = (ShiroUser) SecurityUtils.getSubject().getPrincipal();
		if(user == null){
			rrequest.getWResponse().getMessageCollector().alert("用户没有登陆", true);
		}else{
			rrequest.getRequest().setAttribute("loginUser", user);
			logger.info(user.getName());
		}
		
		super.doStart(rrequest);
	}

}

